×
☰ See All Chapters

Oracle LTRIM and RTRIM Function

Oracle LTRIM/RTRIM functions is way of clipping part of a string (SET) from the string to be trimmed (CHARACTER SET) Oracle LTRIM function clips the part of the string from left and RTRIM function clips the part of the string form right.

Oracle LTRIM and RTRIM Function Syntax

RTRIM(CHARACTERSET, SET)

LTRIM(CHARACTERSET, SET)

CHARACTERSET: Source string to be trimmed.

SET: The string to be trimmed.

MySQL LTRIM and RTRIM Function Example

Creating table for demonstrating LTRIM and RTRIM Function

CREATE TABLE NAME

(

  FNAME  VARCHAR(10 )    NOT NULL,

  LNAME  VARCHAR(10 )

);

Insert into NAME (FNAME, LNAME) Values ('ADI', 'TEMP');

Insert into NAME (FNAME, LNAME) Values ('NAVEEN', 'SHETTY');

Insert into NAME (FNAME, LNAME) Values ('ARJUN', 'SHETTY');

Insert into NAME (FNAME, LNAME) Values ('HARISH', 'GOWDA');

Insert into NAME (FNAME, LNAME) Values ('HARI', 'PRASAD');

Insert into NAME (FNAME, LNAME) Values ('ARJUN', 'SHETTY');

Insert into NAME (FNAME, LNAME) Values ('KIRAN', 'KUMAR');

COMMIT;

Example 1

SELECT  FNAME,LTRIM('TEMP','TE'),RTRIM('SHETTY','TY')

FROM NAME

oracle-ltrim-function-and-rtrim-function-0

Example 2

SELECT  FNAME,LNAME,LTRIM(FNAME,'HA'),RTRIM(LNAME,'TY')

FROM NAME

oracle-ltrim-function-and-rtrim-function-1


All Chapters
Author